<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Fetch</title>
</head>

<body>
    <article>
        <h1>Fetch学习</h1>
    </article>
</body>
<script>
    var headers,
        g_response;
    fetch('./data.txt')
        .then(function (response) {
            g_response = response;
            headers = response.headers;
            console.log(response.ok);
            console.log(response.bodyUsed);
            return response.text();
        })
        .then(function(data){
            console.log(data);
        });
</script>

</html>